package packAutomatricula;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class JDMasAsig extends JDialog {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel lblTodavaTienesCrditos;
	private JLabel lblquieresElegirAlguna;
	private JButton btnNo;
	private JButton btnSi;
	
	private boolean SiNo;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JDMasAsig dialog = new JDMasAsig();
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public JDMasAsig() {
		initialize();
	}
	
	public boolean getValor(){
		return SiNo;
	}
	
	private void initialize() {
		setModal(true);
		setBounds(100, 100, 313, 174);
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(43)
							.addComponent(getLblTodavaTienesCrditos()))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(32)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(55)
									.addComponent(getBtnNo())
									.addGap(18)
									.addComponent(getBtnSi()))
								.addComponent(getLblquieresElegirAlguna()))))
					.addContainerGap(174, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(28)
					.addComponent(getLblTodavaTienesCrditos())
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(getLblquieresElegirAlguna())
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(getBtnNo())
						.addComponent(getBtnSi()))
					.addContainerGap(145, Short.MAX_VALUE))
		);
		getContentPane().setLayout(groupLayout);
	}

	private JLabel getLblTodavaTienesCrditos() {
		if (lblTodavaTienesCrditos == null) {
			lblTodavaTienesCrditos = new JLabel("Todav\u00EDa tienes cr\u00E9ditos disponibles");
		}
		return lblTodavaTienesCrditos;
	}
	private JLabel getLblquieresElegirAlguna() {
		if (lblquieresElegirAlguna == null) {
			lblquieresElegirAlguna = new JLabel("\u00BFQuieres elegir alguna asignatura m\u00E1s?");
		}
		return lblquieresElegirAlguna;
	}
	private JButton getBtnNo() {
		if (btnNo == null) {
			btnNo = new JButton("No");
			btnNo.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					SiNo = false;
					cerrar();
				}
			});
		}
		return btnNo;
	}
	private JButton getBtnSi() {
		if (btnSi == null) {
			btnSi = new JButton("S\u00ED");
			btnSi.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent arg0) {
					SiNo = true;
					cerrar();
				}
			});
		}
		return btnSi;
	}
	
	private void cerrar(){
		this.setVisible(false);
	}
}
